package cn.calm.study.hibernate.many2one;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

/**
 * 对话框
 * 
 * @author Administrator
 * 
 */
@Entity(name = "t_dialog")
public class Dialog implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String id;

	/**
	 * 对话框的基本内容
	 */
	private String content;
	/**
	 * 标题
	 */
	private String title;
	/**
	 * 宽度
	 */
	private Integer width;
	/**
	 * 高度
	 */
	private Integer height;
	/**
	 * 自动打开
	 */
	private Integer autoOpen;
	/**
	 * 自动打开
	 */
	public static final int AUTO_OPEN_TRUE = 1;
	/**
	 * 不自动打开
	 */
	public static final int AUTO_OPEN_FALSE = 0;
	/**
	 * 是否可变大小
	 */
	private Integer resizable;
	/**
	 * 可变大小
	 */
	public static final int RESIZABLE_TRUE = 1;
	/**
	 * 不可变大小
	 */
	public static final int RESIZABLE_FALSE = 0;

	/**
	 * 是否模态
	 */
	private Integer modal;
	/**
	 * 模态对话框
	 */
	public static final int MODAL_TRUE = 1;
	/**
	 * 非模态对话框
	 */
	public static final int MODAL_FALSE = 0;
	/**
	 * 是否分页
	 */
	private Integer pager;
	/**
	 * 分页
	 */
	public static final int PAGER_TRUE = 1;
	/**
	 * 不分页
	 */
	public static final int PAGER_FALSE = 0;

	/**
	 * 按钮
	 */
	private Set<Button> buttons;

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Integer getAutoOpen() {
		return autoOpen;
	}

	public void setAutoOpen(Integer autoOpen) {
		this.autoOpen = autoOpen;
	}

	public Integer getWidth() {
		return width;
	}

	public void setWidth(Integer width) {
		this.width = width;
	}

	public Integer getHeight() {
		return height;
	}

	public void setHeight(Integer height) {
		this.height = height;
	}

	@OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, mappedBy = "dialog")
	public Set<Button> getButtons() {
		if (buttons == null) {
			buttons = new HashSet<Button>();
		}
		return buttons;
	}

	public void setButtons(Set<Button> buttons) {
		this.buttons = buttons;
	}

	public Integer getModal() {
		return modal;
	}

	@Transient
	public String getDisplayModal() {
		return null;
	}

	public void setModal(Integer modal) {
		this.modal = modal;
	}

	public Integer getResizable() {
		return resizable;
	}

	public void setResizable(Integer resizable) {
		this.resizable = resizable;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Integer getPager() {
		return pager;
	}

	public void setPager(Integer pager) {
		this.pager = pager;
	}

	@Id
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

}
